#include "type.h"

extern "C" {
    type_t g_basic_types[VOID - CHAR + 1];
	type_t g_string_type;
}

extern "C" void init_basic_types()
{
	int i;
	// FunctionType fty;
	/**
	 setup type size for each type.
		some elements in Types[] are just place-holders.
		e.g.  ENUM,  ?
	 */
	T(CHAR)->size = T(UCHAR)->size = CHAR_SIZE;
	T(SHORT)->size = T(USHORT)->size = SHORT_SIZE;
	T(INT)->size = T(UINT)->size = INT_SIZE;
	T(LONG)->size = T(ULONG)->size = LONG_SIZE;
	T(LONGLONG)->size = T(ULONGLONG)->size = LONG_LONG_SIZE;
	T(FLOAT)->size = FLOAT_SIZE;
	T(DOUBLE)->size = DOUBLE_SIZE;
	T(LONGDOUBLE)->size = LONG_DOUBLE_SIZE;
	T(POINTER)->size = INT_SIZE;
	/* without this, TypeToString() would have Segmentation fault */
	T(POINTER)->bty = T(INT);

	/* type category, type alignment */
	for (i = CHAR; i <= VOID; ++i)
	{
		T(i)->categ = i;
		T(i)->align = T(i)->size;
	}
	g_string_type.size = 8;
	g_string_type.bty = T(CHAR);
}